package com.example.subject10mvn.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
@Data
@EntityListeners(AuditingEntityListener.class)
public class Subject {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer subjectId;

    private Integer subjectTypeId;

    private String stem;

    private String options;

    private String answer;

    @ManyToOne(targetEntity = SubjectType.class,fetch = FetchType.EAGER)
    @JoinColumn(name = "subjectTypeId",referencedColumnName = "subjectTypeId",insertable = false,updatable = false)
    private SubjectType subjectType;

    @CreatedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @LastModifiedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

}
